package com.ruoyi.crm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.crm.domain.CrmFeeApply;
import com.ruoyi.crm.domain.CrmOrderProductDiscount;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.CrmOrderCollectPayMoney;
import com.ruoyi.crm.service.ICrmOrderCollectPayMoneyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收付款管理Controller
 *
 * @author yanwenliang
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/crm/collectPayMoney")
public class CrmOrderCollectPayMoneyController extends BaseController
{
    @Autowired
    private ICrmOrderCollectPayMoneyService crmOrderCollectPayMoneyService;

    /**
     * 查询收付款管理列表
     */
    // @PreAuthorize("@ss.hasPermi('crm:collectPayMoney:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmOrderCollectPayMoney crmOrderCollectPayMoney)
    {
        startPage();
        List<CrmOrderCollectPayMoney> list = crmOrderCollectPayMoneyService.selectCrmOrderCollectPayMoneyList(crmOrderCollectPayMoney);
        return getDataTable(list);
    }

    /**
     * 导出收付款管理列表
     */
    // @PreAuthorize("@ss.hasPermi('crm:collectPayMoney:export')")
    @Log(title = "收付款管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CrmOrderCollectPayMoney crmOrderCollectPayMoney)
    {
        List<CrmOrderCollectPayMoney> list = crmOrderCollectPayMoneyService.selectCrmOrderCollectPayMoneyList(crmOrderCollectPayMoney);
        ExcelUtil<CrmOrderCollectPayMoney> util = new ExcelUtil<CrmOrderCollectPayMoney>(CrmOrderCollectPayMoney.class);
        util.exportExcel(response, list, "收付款管理数据");
    }

    /**
     * 获取收付款管理详细信息
     */
    // @PreAuthorize("@ss.hasPermi('crm:collectPayMoney:query')")
    @GetMapping(value = "/{collectPayMoneyId}")
    public AjaxResult getInfo(@PathVariable("collectPayMoneyId") String collectPayMoneyId)
    {
        return success(crmOrderCollectPayMoneyService.selectCrmOrderCollectPayMoneyByCollectPayMoneyId(collectPayMoneyId));
    }

    /**
     * 新增收付款管理
     */
    // @PreAuthorize("@ss.hasPermi('crm:collectPayMoney:add')")
    @Log(title = "收付款管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmOrderCollectPayMoney crmOrderCollectPayMoney)
    {
        return toAjax(crmOrderCollectPayMoneyService.insertCrmOrderCollectPayMoney(crmOrderCollectPayMoney));
    }

    /**
     * 修改收付款管理
     */
    // @PreAuthorize("@ss.hasPermi('crm:collectPayMoney:edit')")
    @Log(title = "收付款管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmOrderCollectPayMoney crmOrderCollectPayMoney)
    {
        return toAjax(crmOrderCollectPayMoneyService.updateCrmOrderCollectPayMoney(crmOrderCollectPayMoney));
    }

    /**
     * 删除收付款管理
     */
    // @PreAuthorize("@ss.hasPermi('crm:collectPayMoney:remove')")
    @Log(title = "收付款管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collectPayMoneyIds}")
    public AjaxResult remove(@PathVariable String[] collectPayMoneyIds)
    {
        return toAjax(crmOrderCollectPayMoneyService.deleteCrmOrderCollectPayMoneyByCollectPayMoneyIds(collectPayMoneyIds));
    }

    /**
     * 审核
     *
     * @param crmOrderCollectPayMoney
     * @return
     */
    @PostMapping("/audit")
    public AjaxResult audit(@RequestBody CrmOrderCollectPayMoney crmOrderCollectPayMoney) {
        return AjaxResult.success(crmOrderCollectPayMoneyService.audit(crmOrderCollectPayMoney));
    }

    /**
     * 提交
     *
     * @param crmOrderCollectPayMoney
     * @return
     */
    @PostMapping("submit")
    public AjaxResult submit(@RequestBody CrmOrderCollectPayMoney crmOrderCollectPayMoney) {
        return AjaxResult.success(crmOrderCollectPayMoneyService.submit(crmOrderCollectPayMoney));
    }

    /**
     * 回撤提交
     *
     * @param crmOrderCollectPayMoney
     * @return
     */
    @PostMapping("cancelInfo")
    public AjaxResult cancelInfo(@RequestBody CrmOrderCollectPayMoney crmOrderCollectPayMoney) {
        return AjaxResult.success(crmOrderCollectPayMoneyService.cancelInfo(crmOrderCollectPayMoney));
    }

}
